
local ui = class.panel:builder 
{
    x = 1390,
    y = 400,
    w = 530,
    h = 400,
    show_flag = false,
    alpha = 0.99,
    fdf = 'tooltip_backdrop1',
}
ui:set_level(99)
ac.tools = ui

--标题
ui.title = ui:add_text('标题',12,10,ui.w,25,12)

--介绍
ui.tip = ui:add_text('',12,50,ui.w-30,0,11)


ac.game:event '游戏-关闭天赋介绍'(function()
    ui.button = nil
    ui:hide()
end)

ac.game:event '游戏-显示天赋介绍'(function(_,self,title,tip,anchor)
    local ex_h = 0
    local width = width or 530
    ui:set_width(width)
    japi.FrameSetPoint(japi.FrameGetTooltip(), 8, japi.GetGameUI(), 8, 0.3, 0.16)

    ui.title:set_text(title)

    --设置内容
    ui.tip:set_text(tip)
    ui.tip:set_position(ui.tip.x, ui.title.y + ui.title.h + ex_h + 5)
    
    --位置
    local height = ui.tip.y + ui.tip:get_height() + 10
    ui:set_height(height)
    if anchor then 
        if anchor=='auto' then
            local x,y = self:get_real_position()
            if y>1080/2 then
                self:set_tooltip_follow(ui, 'top')
            else
                self:set_tooltip_follow(ui, 'bottom')
            end
        else
            self:set_tooltip_follow(ui, anchor)
        end
    else 
        local x, y = 1390, 785 - ui.h 
        ui:set_position(x, y)
    end 
    ui.button = self
    ui:show()
end)

ac.game:event '玩家-刷新UI'(function(_,player)
    if player:is_self() then
        local button = ui.button
        if button then
            button:notify('on_button_mouse_enter',button)
        end
    end
end)